#include "MTForStatement.hpp"
#include "MTExpression.hpp"
#include "MTBlock.hpp"
#include "MTVariableDefinition.hpp"
#include <iostream>
#include <sstream>
#include <string>

namespace MathematicaTranslator
{
 	std::string* MTForStatement::generateCode(CodeGenContext& context)
	{
		std::ostringstream ss;
		ss << "for (";
		for (int i = varList.size() - 1; i>=0; --i){
			ss << *varList[i]->generateCode(context);
			if (i>0) ss << ", ";
		}
		ss << "; ";
		ss << *conditions.generateCode(context);
		ss << "; ";
		for (int i = incrementList.size() - 1; i>=0; --i){
			ss << *incrementList[i]->generateCode(context);
			if (i>0) ss << ", ";
		}
		ss << ") {\n   ";
		ss << *body.generateCode(context);
		ss << "}";

		return new std::string(ss.str());
	}
}